<div id="changesets">
    <span class="actions">
        <a id="createChangeset" href="#">Create New</a>
    </span>
    <h3 class="section">Changesets [<?php echo $updater->getVersion(); ?>]</h3>
    <div class="form changeset" style="display:none">
        <h4>Create a new Changeset</h4>
        <form action="index.php?controller=generator&action=changeset" method="POST">
            <p>
                <label>Name:</label>
                <input type="text" name="name" value="" />
                <input type="submit" name="submit" value="Create" />
            </p>
        </form>
    </div>
    <div class="content">
        <?php  $changesets = array_reverse($updater->getChangesets(), true); ?>

        <?php if (is_array($changesets) && count($changesets)) { ?>
            <ul class="list">
            <?php foreach ($changesets as $changeset=>$files) { ?>
                <?php $runned = ((int)$changeset <= (int)$version); ?>
                <li class="changeset<?php echo ($runned) ? ' runned': ''; ?>" >

                    <span class="actions">
                        <a href="?controller=changesets&action=run&changeset=<?php echo $changeset; ?>">Run</a> |
                    <?php if (!$runned) { ?>
                        <a href="?controller=changesets&action=update&changeset=<?php echo $changeset; ?>">Update</a> |
                        <a href="?controller=generator&action=delete&changeset=<?php echo $changeset; ?>" onclick="return confirm('Are u sure you ?');">Delete</a> |
                        <a class="createFile" href="#" >CreateFile</a>
                    <?php } ?>
                    </span>
                    
                    <strong class="name">Changeset #<?php echo $changeset; ?></strong>

                    <?php if (!$runned) { ?>
                        <div class="form file" style="display:none">
                            <h4>Create a new File</h4>
                            <form action="index.php?controller=generator&action=file&changeset=<?php echo $changeset; ?>" method="POST">
                                <p>
                                    <label>Name:</label>
                                    <input type="text" name="name" value="" />
                                    <input type="submit" name="submit" value="Create" />
                                </p>
                            </form>
                        </div>
                    <?php } ?>

                    <?php if (is_array($files)) { ?>
                        <ul class="files" style="<?php echo ($runned) ? ' display:none': ''; ?>">
                        <?php foreach ($files as $file) { ?>
                            <li class="file">
                                <span class="name"><?php echo $file; ?></span>
                                <?php if (!$runned) { ?>
                                    <form action="index.php?controller=generator&action=content&changeset=<?php echo $changeset; ?>&file=<?php echo $file; ?>" method="POST">
                                        <textarea name="content" class="content"><?php echo $updater->fileContent($file, $changeset); ?></textarea>
                                        <input type="submit" name="submit" value="Update" />
                                    </form>
                                <?php } else { ?>
                                    <pre><?php echo $updater->fileContent($file, $changeset); ?></pre>
                                <?php } ?>
                            </li>
                        <?php } ?>
                        </ul>
                    <?php } ?>
                </li>
            <?php } ?>
            </ul>
        <?php } else { ?>
            <p>No Changes</p>
        <?php } ?>
    </div>
</div>